package com.aididi.config;

import com.aididi.filter.CharacterEncodingFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class WebFilterConfig {
    /**
     *  配置自定义过滤器或者第三方提供的过滤器
     * @return
     */
    public FilterRegistrationBean MyFilter(){
        // 此对象效果等同于 web.xml中的过滤器的配置
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
        filterRegistrationBean.setFilter(encodingFilter);
        filterRegistrationBean.setOrder(1);
        return filterRegistrationBean;
    }
}
